package co.yixiang.modules.shop.web.controller;

import co.yixiang.annotation.AnonymousAccess;
import co.yixiang.aop.log.Log;
import co.yixiang.common.api.ApiResult;
import co.yixiang.common.web.controller.BaseController;
import co.yixiang.modules.shop.entity.DictDetail;
import co.yixiang.modules.shop.service.DictDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Api(value = "字典管理", tags = "字典管理", description = "字典管理")
public class DictController extends BaseController {
    private final DictDetailService dictDetailService;

    @Log("字典数据")
    @AnonymousAccess
    @ApiOperation(value = "字典数据", notes = "字典数据")
    @GetMapping(value = "/dict/findDictName")
    public ApiResult findDictName(@ApiParam(value = "字典名称", name = "name")@RequestParam String name) {
        List<DictDetail> list = dictDetailService.findDictName(name);
        return ApiResult.ok(list);
    }
}
